<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Call</title>
</head>
<body>
    <script>
        function myCall(fn, target){
            // 获取函数执行时实际参数
            var arg = Array.prototype.slice.call(arguments, 2);
            // console.log(arg);
            target = target || {};
            // 将函数挂载到target上并执行  变相的修改了this指向
            target.fn = fn;
            return target.fn(...arg);
        }

        function print(x){
            console.log(x);
        }
        myCall(print, null, 2);
    </script>
</body>
</html>